FROM golang:1.16.1-buster as gobuilder

ADD . /out_plugins
WORKDIR /out_plugins
ENV GOOS linux
ENV GOARCH amd64
ENV CGO_ENABLED=1
ENV GOFLAGS "-ldflags=-w -ldflags=-s"
ENV GO111MODULE=on
ENV GOFLAGS=" -mod=vendor"
ENV GOPROXY=https://yz271544:UbFWoA20KLRShpM@goproxy.io,direct

RUN make prod

FROM fluent/fluent-bit:v1.8.0-107-g73694cc7

COPY --from=gobuilder /out_plugins/out_mqtt.* /usr/lib/x86_64-linux-gnu/
COPY --from=gobuilder /out_plugins/conf/fluent-bit.conf /fluent-bit/etc/
COPY --from=gobuilder /out_plugins/conf/plugins.conf /fluent-bit/etc/

EXPOSE 2020

# CMD ["/fluent-bit/bin/fluent-bit", "--plugin", "/usr/lib/x86_64-linux-gnu/out_mqtt.so", "--config", "/fluent-bit/etc/fluent-bit.conf"]
CMD ["/fluent-bit/bin/fluent-bit", "--config", "/fluent-bit/etc/fluent-bit.conf"]
